![]() |
PATH![]() |
![]() ![]() |
Downloads data synchronously from a URL into a file, a directory, or memory using a URL reference.
OSStatus URLDownload (
URLReference urlRef,
FSSpec* destination,
Handle destinationHandle,
URLOpenFlags openFlags,
URLSystemEventProcPtr eventProc,
void* userContext);
The URLDownload function downloads data synchronously from a specified URL to a specified file or directory and does not return until the download is complete. The URLDownload function yields time to other threads. Your application should call URLDownload from a thread other than the main thread so that other processes have time to run.
If you want a progress indicator to be displayed during the download, specify kURLDisplayProgressFlag in the openFlags parameter. The URL Access Manager uses a modal dialog box to display the progress indicator. If your application has multiple threads, it can call URLDownload multiple times, but if it calls URLDownload with kURLDisplayProgressFlag set in openFlags when the URL Access Manager is already displaying a modal dialog box, URLDownload returns the error kURLProgessAlreadyDisplayedError .
If the URL reference specifies a file, the file is downloadedregardless of whether kURLDirectoryListingFlag or KURLIsDirectoryHintFlag is set in the openFlags parameter.
When URLDownload downloads data from a file:/// URL, the data fork is downloaded but the resource fork is not downloaded.
WARNING
Once you call URLDownload with urlRef , you cannot use the same urlRef to call URLDownload again, or to call URLUpload or URLOpen . If you need to call URLDownload , URLUpload , or URLOpen with a urlRef that has already been used for one of these calls, you need to create a new URL reference by calling URLNewReference .
Call URLOpen if you need to control the download process.